package com.uzai.console.web.faq.privitawork;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.entity.BaseEntity;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.device.DeviceQuery;
import com.uzai.console.dto.faq.faqreplygroup.BatchUpdateFaqReplyGroupDto;
import com.uzai.console.dto.faq.faqreplygroup.FaqReplyGroupDto;
import com.uzai.console.dto.faq.faqreplygroup.FaqReplyGroupIdDto;
import com.uzai.console.dto.faq.faqreplygroup.FaqReplyGroupQuery;
import com.uzai.console.dto.faq.privatework.*;
import com.uzai.console.dto.pyq.pyqautoconfig.PyqAutoConfigStatusDto;
import com.uzai.console.entity.FaqReplyGroup;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.faq.privatework.FaqReplyGroupService;
import com.uzai.console.service.faq.privatework.FaqReplyService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.faq.faqreplygroup.FaqReplyGroupVo;
import com.uzai.console.vo.faq.privatework.FaqReplyInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 智能回复|个微/企微词库
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "个微企微词库",tags = "智能回复|个微企微词库")
@ApiSort(16)
@RestController
public class FaqReplyController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(FaqReplyController.class);

    @Autowired
    private FaqReplyService faqReplyService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private FaqReplyGroupService faqReplyGroupService;

    @ApiOperation(value = "查询回复语分页列表", notes = "查询回复语分页列表", response = FaqReplyInfoVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/faqReply/findFaqReplyList")
    public Object findFaqReplyList(@RequestBody FaqReplyQuery faqReplyQuery){
        return faqReplyService.findFaqReplyList(faqReplyQuery);
    }

    @ApiOperation(value = "查询回复语详情", notes = "查询回复语详情", response = FaqReplyInfoVo.class)
    @ApiOperationSupport(order= 4)
    @PostMapping("/faqReply/findFaqReplyInfo")
    public Object findFaqReplyInfo(@RequestBody FaqReplyIdDto faqReplyIdDto){
        return faqReplyService.findFaqReplyInfo(faqReplyIdDto);
    }

    @SystemLogType(model = SystemModelEnum.FaqReplyPrivate, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改回复语", notes = "修改回复语")
    @ApiOperationSupport(order = 5)
    @PostMapping("/faqReply/updateFaqReply")
    public Object updateFaqReply(@RequestBody FaqReplyInfoDto faqReplyInfoDto){
        faqReplyService.updateFaqReply(faqReplyInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FaqReplyPrivate, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加回复语", notes = "添加回复语")
    @ApiOperationSupport(order = 6)
    @PostMapping("/faqReply/addFaqReply")
    public Object addFaqReply(@RequestBody FaqReplyInfoDto faqReplyInfoDto){
        faqReplyService.addFaqReply(faqReplyInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FaqReplyPrivate, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除回复语", notes = "删除回复语")
    @ApiOperationSupport(order = 7)
    @PostMapping("/faqReply/deleteFaqReply")
    public Object deleteFaqReply(@RequestBody FaqReplyIdListDto faqReplyIdListDto){
        faqReplyService.deleteFaqReply(faqReplyIdListDto);
        return true;
    }

    @ApiOperation(value = "开启关闭回复语", notes = "开启关闭回复语", response = Boolean.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/faqReply/updateStatus")
    public Object updateStatus(@RequestBody FaqReplayStatusDto faqReplayStatusDto){
        faqReplyService.updateStatus(faqReplayStatusDto);
        return true;
    }

    @ApiOperation(value = "查询机器人类型下拉列表", notes = "查询机器人类型下拉列表", response = SelectKeyVo.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/faqReply/findDeviceTypeSelect")
    public Object findFaqDeviceList(){
        List<SelectKeyVo> selectKeyVoList = new ArrayList<>();
        //个人微信
        SelectKeyVo  selectKeyVo_private = new SelectKeyVo();
        selectKeyVo_private.setKey(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        selectKeyVo_private.setValue(DeviceTypeEnum.DT_PC_WECHAT.getDesc());
        selectKeyVoList.add(selectKeyVo_private);
        //企业微信
        SelectKeyVo  selectKeyVo_work = new SelectKeyVo();
        selectKeyVo_work.setKey(DeviceTypeEnum.DT_WORK_WECHAT.getKey());
        selectKeyVo_work.setValue(DeviceTypeEnum.DT_WORK_WECHAT.getDesc());
        selectKeyVoList.add(selectKeyVo_work);

        return selectKeyVoList;
    }

    @ApiOperation(value = "查询机器人列表", notes = "查询机器人列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 9)
    @PostMapping("/faqReply/findDeviceList")
    public Object findFaqDeviceList(@RequestBody DeviceQuery deviceQuery){
        return deviceService.findDeviceList(deviceQuery);
    }

    @ApiOperation(value = "分页查询回复语分组", notes = "分页查询回复语分组", response = FaqReplyGroupVo.class)
    @ApiOperationSupport(order = 10)
    @PostMapping("/faqReplyGroup/findByPage")
    public Object findFaqReplyGroupByPage(@RequestBody FaqReplyGroupQuery faqReplyGroupQuery){
        return faqReplyGroupService.findFaqReplyGroupByPage(faqReplyGroupQuery);
    }

    @ApiOperation(value = "查询回复语分组详情", notes = "查询回复语分组详情", response = FaqReplyInfoVo.class)
    @ApiOperationSupport(order= 11)
    @PostMapping("/faqReplyGroup/findById")
    public Object updateFaqReplyGroup(@RequestBody FaqReplyGroupIdDto faqReplyGroupIdDto){
        return faqReplyGroupService.findFaqReplyGroup(faqReplyGroupIdDto);
    }

    @SystemLogType(model = SystemModelEnum.FaqReplyPrivate, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改回复语分组", notes = "修改回复语分组")
    @ApiOperationSupport(order = 12)
    @PostMapping("/faqReplyGroup/update")
    public Object updateFaqReplyGroup(@RequestBody FaqReplyGroupDto faqReplyGroupDto){
        faqReplyGroupService.updateFaqReplyGroup(faqReplyGroupDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FaqReplyPrivate, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加回复语分组", notes = "添加回复语分组")
    @ApiOperationSupport(order = 13)
    @PostMapping("/faqReplyGroup/add")
    public Object addFaqReplyGroup(@RequestBody FaqReplyGroupDto faqReplyGroupDto){
        faqReplyGroupService.addFaqReplyGroup(faqReplyGroupDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FaqReplyPrivate, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除回复语分组", notes = "删除回复语分组")
    @ApiOperationSupport(order = 14)
    @PostMapping("/faqReplyGroup/delete")
    public Object deleteFaqReplyGroup(@RequestBody FaqReplyGroupIdDto faqReplyGroupIdDto){
        faqReplyGroupService.deleteFaqReplyGroup(faqReplyGroupIdDto);
        return true;
    }

    @ApiOperation(value = "查询回复语分组列表", notes = "查询回复语分组列表", response = FaqReplyGroupVo.class)
    @ApiOperationSupport(order = 15)
    @PostMapping("/faqReplyGroup/findByList")
    public Object findFaqReplyGroupByList(@RequestBody FaqReplyGroupQuery faqReplyGroupQuery){
        return faqReplyGroupService.findFaqReplyGroupByList(faqReplyGroupQuery);
    }

    @ApiOperation(value = "批量编辑回复语分组", notes = "批量编辑回复语分组", response = Boolean.class)
    @ApiOperationSupport(order = 16)
    @PostMapping("/faqReplyGroup/batchUpateFaqReplyGroup")
    public Object batchUpateFaqReplyGroup(@RequestBody BatchUpdateFaqReplyGroupDto batchUpdateFaqReplyGroupDto){
        faqReplyGroupService.batchUpateFaqReplyGroup(batchUpdateFaqReplyGroupDto);
        return true;
    }
}
